var jjnr = '';
var jjxxld = "";
var navigation = [];
function getCmsList(channel,pageNumber,pageSize,callback){
    var param = {
        channelId : channel,
        pageNumber:pageNumber,
        pageSize:pageSize
    }
    $.post(window.serviceUrl+"content/getContentList", param, callback, 'json');
}
function getCmsJianJie(callback){
    var param = {
    }
    $.post(window.serviceUrl+"content/getCmsJianJie", param, callback, 'json');
}


function showCmsJianJie(){
    getCmsJianJie(function(data){
        if(data.rtnCode == "000000"){
            getBanner("xxgk");
            getJjzcsp("xxgk");
            //getMyJjzcsp(data.responseData.jjzcsp);
            jjnr = data.responseData.jjnr;
            jjxxld = data.responseData.jjxxld;
            navigation = data.responseData.navigation;
            showNavigation(navigation);
            var tag = fnGet("tag");
            if(tag){
                var id = $('*[tag="'+tag+'"]').data("id");
                $('*[tag="'+tag+'"]').addClass("open");
                $("#channelName").html($('*[tag="'+tag+'"]').find("a").html());
                getByTag(tag,id);
            }else{
                getJjContent(jjnr);
            }
            $("#accordion").children().on("click",function(){
                tag = $(this).attr("tag");
                var id = $(this).data("id");
                getByTag(tag,id);
                $(this).addClass("open").siblings().removeClass("open");
                $("#channelName").html( $(this).find("a").html());
            })
        }
    });
}

function showNavigation(list){
    var tag = '';
    $.each(list, function(i, item){
        if(item.name != '本级' && item.name != '学校简介' && item.name != '学校领导'){
            if(item.name == '学校动态')
                tag = 'jjxxdt';
            else if(item.name == '校园风采')
                tag = 'jjxyfc';
            var $li = $('<li class="cid_824 " tag="'+tag+'" data-id="'+item.id+'"><div class="linke"> <a href="javascript:void(0)">'+item.name+'</a></div> </li>');
            $("#accordion").append($li);
            var id = item.id;
            $li.on("click",function(){
                channel = id;
                init();
            });
        }
    });
}
function getByTag(tag,id){
    if(tag=='jjnr'){
        $("#jianjie").show();
        $("#lists").hide();
        getJjContent(jjnr);
    }
    else if(tag=='jjxxld'){
        $("#jianjie").show();
        $("#lists").hide();
        getJjContent(jjxxld);
    }
    else{
        $("#jianjie").hide();
        $("#lists").show();
        channel = id;
        init();
    }
}
function getMyBanner(list){
    var content = "";
    $.each(list, function(i, item){
        content += '<li>\n' +
            '                    <a href="detail.html?id='+item.id+'&channel1='+document.title+'" target="_blank" title="">\n' +
            '                        <img src="'+window.imgUrl+item.typesimgUrl+'" alt="">\n' +
            '                    </a>\n' +
            '                    <div class="banner-title"><a href=""></a>\n' +
            '                    </div>\n' +
            '                </li>'
    });
    $("#slider").html(content).responsiveSlides({
        auto: true,
        nav: true,
        speed: 500,
        timeout: 4000,
        pager: true,
     //   pause: true,
        pauseControls: true,
        namespace: "callbacks"
    });
}
function getMyJjzcsp(item){
    var content = '<li>\n' +
        '                                            <div class="item">\n' +
        '                                                <a href="detail.html?id='+item.id+'&channel1='+document.title+'" class="vd-icon"><i\n' +
        '                                                        class="glyphicon glyphicon-play"></i></a>\n' +
        '                                                <a href="detail.html?id='+item.id+'&channel1='+document.title+'" target="_blank" title="'+item.title+'"><img\n' +
        '                                                        width="280" height="188" alt="'+item.title+'"\n' +
        '                                                        src="'+window.imgUrl+item.typesimgUrl+'"' +
        '                                                </a>\n' +
        '                                            </div>\n' +
        '                                        </li>';
    $("#spxcp").html(content);
}

function getJjContent(item){
    $("#artitleTitle").html(item.title);
    $("#artitleContent").html(item.contentHtml);
}